#include <stdio.h>
#include <stdlib.h>

//动态存储分配

struct student
{
    int num;
    char *name;
    char sex;
    float score;
};

int main()
{
    printf("\n\n========================================================================\n\n");
    // 1、malloc函数  分配内存空间
    /*
    (类型说明符 * )malloc(size)
    */
    // char *pc =(char *) malloc(10);

    // 2、calloc 函数
    /*
    (类型说明符 * )calloc(n,size)  分配n块长度为size的连续区域
    */
    // struct student *ps = (struct student *)calloc(2, sizeof(struct student));

    // 3、 free  函数  释放内存空间

    struct student *ps;
    ps = (struct student *)malloc(sizeof(struct student));
    ps->name = "张三";
    ps->sex = 'M';
    printf("name=%s,sex=%c", ps->name, ps->sex);

    free(ps);//释放存储空间

    printf("\n\n========================================================================\n\n");
    return 0;
}